R Markdown:
Presentation & Plotly

Jieqian Liu

Aug 9 2021

Developing Data Products: Project 2

This presentation was created as an assignment of Coursera’s Developing Data Products course. The requirements for the assignment are:

- The web page must feature a date and is this date less than two months before submission.
- The web page must be a presentation and must feature an interactive plot that appears to have been created with Plotly.

Here you can see an example of an acceptable assignment from the instructor: Example

Introduction: UK Driver Deaths

This presentation will examine the rate of driver deaths in the UK before and after the introduction of a law requiring seatbelts to be worn. Some notable findings are:

- The passing of the law is not obviously correlated with a drop in driver deaths.
- Looking at only the data with the law passed, there is an increase in deaths. This is likely due to the small sample.
- The increate of gas (petrol) prices, along with greater distances driven, are also correlated with a drop in driver deaths.

Data

The data is a time series giving the monthly totals of car drivers in Great Britain killed or seriously injured Jan 1969 to Dec 1984. Compulsory wearing of seat belts was introduced on 31 Jan 1983.

##  DriversKilled      drivers         front             rear      
##  Min.   : 60.0   Min.   :1057   Min.   : 426.0   Min.   :224.0  
##  1st Qu.:104.8   1st Qu.:1462   1st Qu.: 715.5   1st Qu.:344.8  
##  Median :118.5   Median :1631   Median : 828.5   Median :401.5  
##  Mean   :122.8   Mean   :1670   Mean   : 837.2   Mean   :401.2  
##  3rd Qu.:138.0   3rd Qu.:1851   3rd Qu.: 950.8   3rd Qu.:456.2  
##  Max.   :198.0   Max.   :2654   Max.   :1299.0   Max.   :646.0  
##       kms         PetrolPrice        VanKilled               law     
##  Min.   : 7685   Min.   :0.08118   Min.   : 2.000   BeltsNotReq:169  
##  1st Qu.:12685   1st Qu.:0.09258   1st Qu.: 6.000   BeltsReq   : 23  
##  Median :14987   Median :0.10448   Median : 8.000                    
##  Mean   :14994   Mean   :0.10362   Mean   : 9.057                    
##  3rd Qu.:17203   3rd Qu.:0.11406   3rd Qu.:12.000                    
##  Max.   :21626   Max.   :0.13303   Max.   :17.000                    
##       date     
##  Min.   :1969  
##  1st Qu.:1973  
##  Median :1977  
##  Mean   :1977  
##  3rd Qu.:1981  
##  Max.   :1985

Regressions

Looking at the analysis of variance for the variables in the data set we can see that the enacting of the law does seem to have a significant effect, however this is likely due to the influence of the points, which are only at the end of the time-series data. The price of gas (petrol) also has a significant effect. Distance traveled, however, does not seem to.

## Analysis of Variance Table
## 
## Model 1: DriversKilled ~ date
## Model 2: DriversKilled ~ date + law
## Model 3: DriversKilled ~ date + law + PetrolPrice
## Model 4: DriversKilled ~ date + law + PetrolPrice + kms
##   Res.Df    RSS Df Sum of Sq       F   Pr(>F)    
## 1    190 109549                                  
## 2    189 105904  1    3645.4  6.9352 0.009159 ** 
## 3    188  99370  1    6534.3 12.4314 0.000531 ***
## 4    187  98292  1    1077.2  2.0494 0.153934    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Deaths vs Time

Here we can see the pre- and post-law death counts. There is a clear downward trend over time, even without the law passed. It isn’t clear from this data whether the law had an impact on death counts.

Deaths vs Time (Law Passed)

Looking at only the data with the law passed we can see an increase in deaths. The sample, however, is very small. If we had more years of data it seems likely that we’d see a decreasing trend.

Deaths vs Gas Price

There is a clear downward trend of fewer deaths with increasing gas prices.

Deaths vs Distance Driven

There is a clear downward trend of fewer deaths with increasing distance driven. This is highly counter-intuitive, and suggests missing variables.

Distance Driven vs Gas Price

There is a clear upward trend of increasing gas prices as distances driven increase. This isn’t surprising, as increased demand can be expected to lead to higher prices.

Conclusions

This dataset seems to be much too small to draw any conclusions about the impact of seatbelt laws on driver deaths in the UK. Further, it seems likely that there are missing confounding variables. For example: deaths decrease with petrol price, but they also increase with distance driven, and there is likely a relationship between distance and price.